package com.xky.microserviceconsumermovie.service;

import com.xky.microserviceconsumermovie.domain.User;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author keying.xia
 * @date 2017/12/15
 */
@Component
@Slf4j
public class MyHystrixClientFallbackFactory implements FallbackFactory<UserFeignClient>{


    @Override
    public UserFeignClient create(Throwable throwable) {
        return new UserFeignClient() {
            @Override
            public User findById(Long id) {
                log.error("异常处理");
                User user = new User();
                user.setId(0L);
                return user;
            }
        };
    }
}
